"""
内容:通过首页精挑细选活动左拉一个产品,点击活动产品进入
作者:刘芳
"""
#引入模块
from ECshop.common.base import Base,create_browser_op
import time
#创建一个类
class PageActivity(Base):
    # 定义属性
    url="http://localhost:8080/ecshop/index.php"
    img=("xpath","//img[@src='data/afficheimg/1462847641920447649.jpg']")
    left=("xpath","//div[@class='swiper-button-prev']")
    flor1="div[class='body-goods']>div"

    # 定义方法

    #进入首页
    def page_activity_open_web(self):
        self.base_open_web(self.url)
    #滚动条向下
    def page_activity_roll(self):
        self.base_roll(self.left)

    #点击左移按钮
    def page_activity_click_left(self):
        self.base_click(self.left)
    #点击页面的图片
    def page_activity_click_img(self):
        self.base_click(self.img)

    #获取当前位置
    def page_activity_get_text1(self):
        return self.base_get_text1(self.flor1)
    #退出
    def page_activity_quit(self):
        self.base_quit()
    #查看源代码
    def page_activity_get_attribute(self):
        return self.base_get_attribute1(self.img)

if __name__ == '__main__':
    aa=PageActivity(create_browser_op(r'C:\Users\86184\AppData\Local\Google\Chrome\User Data'))
    aa.page_activity_open_web()
    aa.page_activity_roll()
    time.sleep(5)
    aa.page_activity_click_left()
    time.sleep(2)
    aa.page_activity_click_img()
    time.sleep(5)
    print(aa.page_activity_get_text1())
    # print(aa.page_activity_get_attribute())
    aa.page_activity_quit()
